Cytosim  PI
Cytoskeleton Simulator
glApp Namespace Reference

glApp extends GLUT to manipulate a 2D or 3D display window

Enumerations

enum  UserMode {
  MOUSE_ROTATE, MOUSE_MOVE, MOUSE_ACTIVE, MOUSE_MOVE_XZ,
  MOUSE_SPIN, MOUSE_ZOOM, MOUSE_SET_ROI, MOUSE_MOVE_ROI,
  MOUSE_SELECT, MOUSE_PASSIVE
}
 actions that can be performed with the mouse
 

Functions

void buildfKeyString ()
 build fKeyString[]
 
void nextUserMode (int dir)
 
void dummyDisplay ()
 
void setROI (Vector3)
 
void setROI (Vector3, Vector3)
 
bool insideROI (Vector3)
 
void build ()
 
void init (void(*func)(), int dim, Glossary *glos=0)
 set display function func and dimensionality dim More...
 
void setDIM (int sDIM)
 set dimensionnality (this affects mostly mouse controls) More...
 
int createWindow (const char *=0)
 create a new display window
 
void drawROI (Vector3 roi[2])
 draw rectangle with discontinuous lines
 
void matchROI (int view)
 set the zoom window to the ROI
 
void destroyWindow (int win)
 destroy window More...
 
void enterFullScreen ()
 enter or exit glut full-screen mode
 
void exitFullScreen ()
 enter or exit glut full-screen mode
 
void switchFullScreen ()
 enter or exit glut full-screen mode
 
void windowReshaped (int, int)
 GLUT callback function for window resize event.
 
void travelingTimer (int)
 timer callback for automatic rotation
 
void setScale (real)
 set the range normally visible for zoom = 1
 
ViewcurrentView ()
 return view associated with current window More...
 
void resetView ()
 reset current view
 
void resetAllViews ()
 reset all views
 
void clearMenu (int menuID)
 create a menu with cnt 'unset' entries, using func for callbacks
 
int buildMenu ()
 build menu, and attach it if argument is a valid button (-1: do not attach)
 
void processMenuEvent (int item)
 callback function for the menu build by buildMenu()
 
void attachMenu (int button)
 attach default menu to button
 
void bindFunctionKeys (bool *)
 set array of flags toggled by pressing the function-keys (F1->F12)
 
bool functionKey (int k)
 return true if function 'k' was turned 'on'
 
void toggleFunctionKey (int key)
 toggle one of the function key
 
void help (std::ostream &=std::cout)
 returns a string describing mouse and keyboard driven events
 
void processNormalKey (unsigned char, int mouseX=0, int mouseY=0)
 GLUT callback function for normal keys. More...
 
void processSpecialKey (int key, int mouseX, int mouseY)
 GLUT callback function for arrow/function keys. More...
 
void mouseClick (int button, int state, int x, int y)
 GLUT callback function for mouse button down/up.
 
void mouseMotion (int x, int y)
 GLUT callback function for mouse motion, when a button is pressed.
 
void passiveMouseMotion (int x, int y)
 GLUT callback function for mouse motion, when no button is pressed.
 
void actionFunc (void(*func)(const Vector3 &, int))
 set callback for shift-click, with unprojected down-position
 
void actionFunc (void(*func)(Vector3 &, const Vector3 &, int))
 set callback for shift-click, with unprojected down- and current- mouse positions
 
void displayLabel (const char *fmt,...)
 
void flashText (const char *fmt,...)
 
void flashTimer (int)
 timer for flashText() (this is automatically called)
 
void setDisplay (View const &)
 called before display of scene
 
void endDisplay (View const &, bool)
 called after display of scene
 
void mainDisplay ()
 display function for main window More...
 
void plainDisplay ()
 display function for secondary windows More...
 
void displayFunc (void(*func)())
 set display function
 
void postRedisplay ()
 this will call glutPostRedisplay() for all windows open by glApp More...
 

Variables

glAppProp GP ("*")
 parameters for glApp
 
std::vector< Viewviews
 different View associated with the display windows
 
int mDIM = 3
 current dimensionality
 
int mZoomWindow = -1
 Window-ID for detailed view.
 
int specialKeys = 0
 state of special keys given by GLUT
 
bool fKeyArray [17]
 default array of function-key states
 
bool * fKey = fKeyArray
 pointer to function-key states changed by bindFunctionKeys()
 
char fKeyString [4 *17]
 String to display function-key states.
 
int actionValidity [] = { 3, 2, 2, 3, 2, 2, 2, 4, 4, 0 }
 Specifies in which dimensionality each action is valid.
 
UserMode userMode = MOUSE_ROTATE
 the current mode (this decide which action is done with the mouse)
 
View mouseView ("backup")
 
UserMode mouseAction = MOUSE_MOVE
 the action being performed by the mouse
 
Vector3 mouseDown
 position where mouse button was pressed down
 
Vector3 depthAxis
 vector normal to desired rotation
 
Vector3 mouseAxis
 axis of rotation for MOUSE_SPIN
 
real mouseZoomScalar
 accessory scalar for zooming
 
Vector3 ROI [2]
 
Vector3 ROIdown [2]
 Regions of interest selected with the mouse.
 
int savedWindowPos [4] = { 512, 512, 10, 10 }
 
real nearZ = 0
 normalized device Z-coordinate-Z of front-plane
 
real midZ = 0.5
 normalized device Z-coordinate-Z of middle
 
real farZ = 1.0
 normalized device Z-coordinate-Z of back-plane
 
bool mouseActive = 0
 
void(* actionFuncClick )(const Vector3 &, int)=0
 function pointer for shift-click actions
 
void(* actionFuncMotion )(Vector3 &, const Vector3 &, int)=0
 function pointer for shift-motion actions
 
bool showResizeBox = false
 display window resize handle
 
unsigned int flash_count = 0
 
std::string flash
 
void(* displayCallback )() = dummyDisplay
 

Function Documentation

void build ( )

start with one single view

View & currentView ( )

this works even if no window is open

void destroyWindow ( int  view)

This will not destroy the main window

void displayLabel ( const char *  fmt,
  ... 
)
Todo:
: replace displayLabel(...) by a std::ostream & display text permanently in bottom-left corner of the window
void flashText ( const char *  fmt,
  ... 
)
Todo:
: replace flashText(...) by a std::ostream & display text for 3 sec (to report that something has been done)
void init ( void(*)()  func,
int  d,
Glossary glos = 0 
)

The first argument is a display callback. The second argument is the dimensionality (2 or 3) that appears to the user.

glutInit() should be called before glApp::init().

bool insideROI ( Vector3  pos)

Only 2D

void mainDisplay ( )

This is used for the main window

void plainDisplay ( )

This is used for any secondary window. It does not show the interactive feedback to user.

void postRedisplay ( )

call glutPostRedisplay() if only the current window needs to be updated

void processNormalKey ( unsigned char  c,
int  mouseX = 0,
int  mouseY = 0 
)
Todo:
flexible key assignment map to accomodate different keyboard layouts
void processSpecialKey ( int  key,
int  mouseX,
int  mouseY 
)

arrow-keys controls translation, and arrow-keys with 'ALT' pressed controls rotation.

motion is reduced by holding down SHIFT.

void setDIM ( int  sDIM)

This will disable OpenGL depth-test for DIM<3

void setROI ( Vector3  a)

Only 2D

void setROI ( Vector3  a,
Vector3  b 
)

Only 2D